from django.core.management.base import BaseCommand
from apps.notify.actions import do_set_is_failed
from utilities.enums import TaskType, ScanJobName

from models.task import ScanTaskSessions


def main():
    query = {
        'job_names': [ScanJobName.site_info.value],
        'status': 9,
        'addition__task_type': TaskType.availability.value
    }
    for item in ScanTaskSessions.objects.filter(**query):
        do_set_is_failed(item)
        print(f"Succeed make task_session_id: {item.task_session_id}")


class Command(BaseCommand):
    def handle(self, *args, **options):
        main()
